package com.yuwei.goods_shopping.mvi

import com.yuwei.common.mvi.BaseViewModel
import retrofit2.http.HEAD

import com.yuwei.database.RoomDBUtils

class GoodsShoppingVIewModel:BaseViewModel<GoodsShoppingApiService,GoodsShoppingIntent>() {
    override fun handleIntent(intent: GoodsShoppingIntent) {
        when(intent){
            is GoodsShoppingIntent.goodsSelectCar ->{
                httpRequest(apiService.goodsSelectCar(),"goodsSelectCar")
            }
            is GoodsShoppingIntent.AddCar ->{
                httpRequest(apiService.AddCar(intent.addCarEntity),"addCar")
            }
            is GoodsShoppingIntent.DeleteCar ->{
                httpRequest(apiService.deleteCar(intent.deleteCarBody),"deleteCar")
            }
            is GoodsShoppingIntent.insertOrder ->{
                roomRequest({ RoomDBUtils.getOrderDao().insertOrder(intent.orderEntity)},"insertOrder")
            }
        }
    }
}